﻿Public Class frmMain
    Private Sub btnNote_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNote.Click
        'Loads frmNotes
        pnlMain.Controls.Clear()
        pnlMain.Controls.Add(frmNotes.plMain)

        'Clears ListView before it is populated
        frmNotes.ListViewSearch.Items.Clear()

        'Populates ListView from Access Database
        Try
            PopulateListViewFromAccess(frmNotes.ListViewSearch)
        Catch ex As Exception
            MessageBox.Show(ex.ToString())
        End Try

        'Loads today date
        frmNotes.DatePicker.Value = System.DateTime.Now

    End Sub

    Private Sub btnPhoneCalls_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPhoneCalls.Click
        'Loads frmPhoneCalls
        pnlMain.Controls.Clear()
        pnlMain.Controls.Add(frmPhoneCalls.plMain)
    End Sub

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        resizeControls()
        Me.MinimumSize = New Size(800, 600)
    End Sub

    Private Sub frmMain_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
        resizeControls()
    End Sub

    Private Sub resizeControls()

        ' Set the width of the tools menu to the width of the form
        pnlTools.Width = Me.Width
        ' Sets the width of the mnu strip to the width of the form
        mnuStripMainMenu.Width = Me.Width
        ' Set the width of the Status strip to the new form width
        ssMain.Width = Me.Width
        ' Undock and redock the Status strip to adjust for the new form size
        ssMain.Dock = DockStyle.None
        ssMain.Dock = DockStyle.Bottom

        For Each c As Control In pnlMain.Controls
            c.Size = pnlMain.Size
            c.Location = New Size(0, 0)
        Next

    End Sub

    Private Sub btnQuizzes_Click(sender As System.Object, e As System.EventArgs) Handles btnQuizzes.Click
        'Loads frmQuizzes
        pnlMain.Controls.Clear()
        pnlMain.Controls.Add(frmQuizzes.plMain)
    End Sub

    Private Sub btnToolbox_Click(sender As System.Object, e As System.EventArgs) Handles btnToolbox.Click
        'Loads frmToolBox
        pnlMain.Controls.Clear()
        pnlMain.Controls.Add(frmToolbox.plMain)
    End Sub

    Private Sub mnuAbout_Click(sender As System.Object, e As System.EventArgs) Handles mnuAbout.Click
        'Loads frmAbout
        frmAbout.Show()
    End Sub

    Private Sub mnuExit_Click(sender As System.Object, e As System.EventArgs) Handles mnuExit.Click
        'Exits Program
        Me.Close()
    End Sub

    Private Sub btnGraphs_Click(sender As System.Object, e As System.EventArgs) Handles btnGraphs.Click
        'Loads frmMainGraphs
        pnlMain.Controls.Clear()
        pnlMain.Controls.Add(frmGraphs.plMain)
    End Sub
End Class
